/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author automne
 */
@Stateless(mappedName="ejb.WordlistFacade")
public class WordlistFacade implements WordlistFacadeRemote {
    @PersistenceContext
    private EntityManager em;

    public void create(Wordlist wordlist) {
        em.persist(wordlist);
    }

    public void edit(Wordlist wordlist) {
        em.merge(wordlist);
    }

    public void remove(Wordlist wordlist) {
        em.remove(em.merge(wordlist));
    }

    public Wordlist find(Object id) {
        //return em.createNativeQuery("select * from wordlist where word = '"+id.toString()+"'");
        return em.find(Wordlist.class, id);
    }

    public List<Wordlist> findAll() {
        return em.createQuery("select object(o) from Wordlist as o").getResultList();
    }

}
